﻿/*
   Open Intel 
   Copyright © 2011 – ISC. All Rights Reserved.
*/

using ISC.MapDotNetServer.Common;
using ISC.MapDotNetServer.Common.Data;
using OI.Framework;

namespace OI.Async
{
    public class MDNDatasetAttributeQuery : MDNFeatureQueryBase
    {
        public string Table { get; private set; }
        public string Where { get; private set; }

        public MDNDatasetAttributeQuery(string table, string where)
        {
            Table = table;
            Where = where;
        }


        protected override QueryRequest BuildQueryRequest()
        {
            return new QueryRequest
            {
                ReturnShapes = false,
                ReturnShapeBounds = false,
                MaxRows = Configuration.MaxSampleQueryRows,
                ReturnResultSetBounds = false,
                ShapeFilterOperation = ShapeFilterOperations.NO_OPERATION,
                ReturnTypes = false
            };
        }


        protected override System.Collections.Generic.IEnumerable<Query> BuildQueries()
        {
            var query = new Query
            {
                DataSourceSpecification = CreateDataSourceSpecication(Table, Utility.SphericalMercatorCoordSys, GeometryTypes.UNINITIALIZED, Where),
                DataSelectionKeyword = Query.DataSelectionKeywords.All,
            };
            query.Fields.Add("*");

            yield return query;
        }
    }
}
